package edu.lsl.springboot.controller;

import edu.lsl.springboot.entity.User;
import edu.lsl.springboot.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @project: SpringBoot
 * @description:
 * @author: dell
 * @date: 2020/11/17 - 16:59
 * @version: 1.0
 * @website:
 */
@RestController
public class UserController {
    @Autowired
    UserRepository userRepository;
    @GetMapping("/user/{id}")
    public User getUser(@PathVariable("id") Integer id){
        User user = (User) userRepository.getOne(id);
        return user;
    }
    @GetMapping("/user")
    public User insertUser(User user){
        User save = userRepository.save(user);
        return save;
    }
}
